package test.my.com.myapplicationtest.fragment_tab_host;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.text.AndroidCharacter;
import android.view.View;

import test.my.com.myapplicationtest.R;

/**
 * Author : Cooper
 * Time : 2016/9/5  10:24
 * Description : 利用FragmentTabHost实现底部tab
 */
public class FragmentTabHostActivity extends FragmentActivity{

    private FragmentTabHost fragmentTabHost;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aty_fragment_tab_host_layout);

        // 找到fragmentTabHost控件
        fragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
        // 设置v4的FragmentManager,用来管理fragment。设置内容fragment容器id
        fragmentTabHost.setup(this,getSupportFragmentManager(),R.id.content_fl);

        View view1 = View.inflate(this,R.layout.tab_indicator_layout,null);
        View view2 = View.inflate(this,R.layout.tab_indicator_layout,null);
        View view3 = View.inflate(this,R.layout.tab_indicator_layout,null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("frist").setIndicator(view1),FristFragment.class,null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("second").setIndicator(view2),SecondFragment.class,null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("thrid").setIndicator(view3),ThridFragment.class,null);
    }
}
